﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication4
{
    public partial class register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string pwd = TextBox2.Text;
            string email = TextBox3.Text;
            string sex= RadioButton1.Checked?"1":"0";
            string conster = "server=.;uid=sa;pwd=123;database=student_db";
            SqlConnection con = new SqlConnection(conster);
            con.Open();
            string sql = "insert into StudentInfo (stu_name,email,gender,[password]) values (@name,@email,@gender,@pwd)";
            SqlParameter[] pars = {
                new SqlParameter("@name",name),
                new SqlParameter("@pwd",pwd),
                new SqlParameter("@email",email),
                new SqlParameter("@sex",sex),
            };
            SqlCommand cmd = new SqlCommand(sql,con);
            cmd.Parameters.AddRange(pars);
            int re = cmd.ExecuteNonQuery();
            if (sqlHelper.Execute(sql, pars))
            {
                Literal1.Text = "注册成功！<a href='Login.aspx'>去登陆</a>";
            }
            else
            {
                Literal1.Text = "注册失败！";
            }




        }
     

    }
}